﻿using System.ComponentModel;
using System.Windows;

namespace Monti.Utilities
{
   /// <summary>
   /// Common utility methods.
   /// </summary>
   public static class Common
   {
      private static bool? s_IsInDesignMode;

      /// <summary>
      /// Gets if we are in design mode or not, needed to disable certain operations.
      /// </summary>
      public static bool IsInDesignMode
      {
         get
         {
            if (!s_IsInDesignMode.HasValue)
            {
               s_IsInDesignMode = (bool)DependencyPropertyDescriptor
                  .FromProperty (DesignerProperties.IsInDesignModeProperty, typeof (FrameworkElement))
                  .Metadata.DefaultValue;
            }

            return s_IsInDesignMode.Value;
         }
      }
   }
}
